/*
 * File:   CharacterServiceImplTest.cpp
 * Author: luk
 *
 * Created on Mar 1, 2015, 9:42:26 PM
 */

#include "CharacterServiceImplTest.h"
#include "CharacterServiceImpl.h"


CPPUNIT_TEST_SUITE_REGISTRATION(CharacterServiceImplTest);

CharacterServiceImplTest::CharacterServiceImplTest() {
}

CharacterServiceImplTest::~CharacterServiceImplTest() {
}

void CharacterServiceImplTest::setUp() {
}

void CharacterServiceImplTest::tearDown() {
}

void CharacterServiceImplTest::testCreate() {
    CharacterServiceImpl characterServiceImpl;

    Character character = characterServiceImpl.create(Attribute(10, 11, 12, 14));

    CPPUNIT_ASSERT_EQUAL_MESSAGE("strength", 10, character.getAttribute().getStrength());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("dexterity", 11, character.getAttribute().getDexterity());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("intelligence", 12, character.getAttribute().getIntelligence());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("health", 14, character.getAttribute().getHealth());

    CPPUNIT_ASSERT_EQUAL_MESSAGE("hit points", 10, character.getCharacteristic().getHitPoints());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("will", 12, character.getCharacteristic().getWill());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("perception", 12, character.getCharacteristic().getPerception());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("fatigue points", 14, character.getCharacteristic().getFatiguePoints());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("basic speed", 6.25f, character.getCharacteristic().getBasicSpeed());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("basic move", 6, character.getCharacteristic().getBasicMove());
    CPPUNIT_ASSERT_EQUAL_MESSAGE("basic lift", 20.0f, character.getCharacteristic().getBasicLift());

    character = characterServiceImpl.create(Attribute(7, 10, 10, 10));

    CPPUNIT_ASSERT_EQUAL_MESSAGE("basic lift", 9.8f, character.getCharacteristic().getBasicLift());
}

void CharacterServiceImplTest::testCharacterSwingingDamage() {
    int TEST_CASE = 22;
    int dice[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3};
    int adds[] = {0, -5, -5, -4, -4, -3, -3, -2, -2, -1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2, 2};

    CharacterServiceImpl characterServiceImpl;

    for (int strength = 0; strength < TEST_CASE; strength++) {
        Character character = characterServiceImpl.create(Attribute(strength, 10, 10, 10));

        std::stringstream diceMessage;
        diceMessage << "dice strength=" << strength;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(diceMessage.str(), dice[strength],
                character.getCharacteristic().getSwingingDamage().getDice());

        std::stringstream addsMessage;
        addsMessage << "adds strength=" << strength;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(addsMessage.str(), adds[strength],
                character.getCharacteristic().getSwingingDamage().getAdds());
    }
}

void CharacterServiceImplTest::testCharacterThrustingDamage() {
    int TEST_CASE = 22;
    int dice[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2};
    int adds[] = {0, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, -1, -1, -1};

    CharacterServiceImpl characterServiceImpl;

    for (int strength = 0; strength < TEST_CASE; strength++) {
        Character character = characterServiceImpl.create(Attribute(strength, 10, 10, 10));

        std::stringstream diceMessage;
        diceMessage << "dice strength=" << strength;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(diceMessage.str(), dice[strength],
                character.getCharacteristic().getThrustingDamage().getDice());

        std::stringstream addsMessage;
        addsMessage << "adds strength=" << strength;
        CPPUNIT_ASSERT_EQUAL_MESSAGE(addsMessage.str(), adds[strength],
                character.getCharacteristic().getThrustingDamage().getAdds());
    }
}
